﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data.Linq;
/// <summary>
/// Summary description for Book
/// </summary>
/// 
namespace SPK
{


    public class BookMange
    {
        public BookMange()
        {
           
        }
        
        public DataSet GetBookType()
        { 
           string   connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
           SqlConnection con = new SqlConnection(connectionString);
           string cmdText = "SELECT * FROM BookType";
           SqlDataAdapter da = new SqlDataAdapter(cmdText, con);
           DataSet ds = new DataSet();
           try
           {   ///打开连接
               con.Open();
               ///填充数据
               da.Fill(ds, "DataTable");
           }
           catch (Exception ex)
           {   ///抛出异常
               throw new Exception(ex.Message, ex);
           }
           finally
           {   ///关闭连接
               con.Close();
           }

           return ds;
        }

        public DataSet GetAllBook()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection con = new SqlConnection(connectionString);
            string cmdText = "SELECT * FROM Book";
            SqlDataAdapter da = new SqlDataAdapter(cmdText, con);
            DataSet ds = new DataSet();
            try
            {   ///打开连接
                con.Open();
                ///填充数据
                da.Fill(ds, "DataTable");
            }
            catch (Exception ex)
            {   ///抛出异常
                throw new Exception(ex.Message, ex);
            }
            finally
            {   ///关闭连接
                con.Close();
            }
            return ds;
           
        }


    }
}
